package fuzzylizard.teamdocs.web;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import wicket.markup.html.basic.Label;
import wicket.markup.html.link.PageLink;
import wicket.markup.html.panel.FeedbackPanel;
import wicket.model.PropertyModel;

/**
 * Understands the Dashbaord.html web page
 * 
 * @author Chris Johnston
 */
public class Dashboard extends SecuredBasePage {

    private Log LOG = LogFactory.getLog(Dashboard.class);
    private FeedbackPanel feedback;
    
    public Dashboard() {
        super();
        createLinks();
        initPage();
        LOG.debug("Using default constructor");
    }
    
//    public Dashboard(final PageParameters parameters) {
//        super();
//        createLinks();
//        initPage();
//        LOG.debug("Using parameters constructor");
//    }
    
    public void initPage() {
        feedback = new FeedbackPanel("feedback");
        add(feedback);
        
        Label loggedInAs = new Label("loggedInAs", new PropertyModel(this, "loggedInAs"));
        add(loggedInAs);
    }

    private void createLinks() {
        add(new PageLink("linkToIndexPage", Index.class));
        add(new PageLink("linkToDashboard", Dashboard.class));
        add(new PageLink("linkToExplorer", Explorer.class));
    }
    
    public String getLoggedInAs() {
        return getTeamdocsSession().getUser().toString();
    }
}
